package ioc

import (
	"github.com/apache/rocketmq-client-go/v2"
	"github.com/apache/rocketmq-client-go/v2/consumer"
	"github.com/apache/rocketmq-client-go/v2/producer"
	"shop_srvs/inventory_srv/global"
)

func InitRocketMQ() {
	var err error
	global.Proceduer, err = rocketmq.NewProducer(
		producer.WithNameServer([]string{"192.168.71.130:9876"}),
		producer.WithInstanceName("inventory_instance"))
	if err != nil {
		panic("生成producer失败")
	}

	global.Consumer, err = rocketmq.NewPushConsumer(
		consumer.WithNameServer([]string{"192.168.71.130:9876"}),
		consumer.WithGroupName("mxshop-inventory"), //指定消费组
	)
	if err != nil {
		panic("生成consumer失败")
	}
}
